{% extends 'base.html' %}

{% block content %}
    <div class="bs-example" data-example-id="basic-forms">
        <form id="form1" method="post">
            {% csrf_token %}
            <div class="form-group">
                <label for="exampleInputEmail1">手机号</label>
                <input type="text" class="form-control" id="exampleInputEmail1" placeholder="手机号" name="phone">
            </div>
            <div class="form-group">
                <label for="exampleInputPassword1">密码</label>
                <input type="password" class="form-control" id="exampleInputPassword1" placeholder="密码1" name="pwd1">
            </div>
            <div class="form-group">
                <label for="exampleInputPassword1">确认密码</label>
                <input type="password" class="form-control" id="exampleInputPassword1" placeholder="密码2" name="pwd2">
            </div>
            <button type="submit" class="btn btn-default" id="but1">注册</button>
        </form>
    </div>
{% endblock %}

{% block js %}
    <script type="text/javascript">
        //函数的入扣
        $(function () {
            but1()
        })

        //执行函数
        function but1() {
            $('#but1').click(function () {
                $.ajax({
                    'url': {% url 'register' %},
                    'type': 'post',
                    'data': $('#form1').val(),
                    'dataType': 'JSON',
                    success: function (res) {
                        console.log(res)

                    }
                })

            })
        }
    </script>
{% endblock %}